import React from 'react'
import { render } from 'react-dom'
import { browserHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import { createStore, applyMiddleware } from 'redux'
import Root from './containers/Root'
import rootReducer from './reducers'
import thunk from 'redux-thunk'
import createLogger from 'redux-logger'

import {getProducts, getMyOrders, getCarts} from './actions'
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
import './index.css'

const middleware = [ thunk ];
if (process.env.NODE_ENV !== 'production') {
  middleware.push(createLogger());
}

const store = createStore(
  rootReducer,
  applyMiddleware(...middleware)
)

console.log(getProducts)
store.dispatch(getProducts(1))
store.dispatch(getMyOrders(1))
store.dispatch(getCarts(1))

const history = syncHistoryWithStore(browserHistory, store)


render(
  <Root store={store} history={history} />,
  document.getElementById('root')
)
